package com.qian.apiserver.service;

import java.math.BigDecimal;
import com.qian.apiserver.entity.GmWithdrawal;
import java.util.Date;
import com.qian.apiserver.dao.WithdrawalDao;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import com.qian.apiserver.service.IWithdrawalService;
import java.lang.String;
import java.lang.Byte;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;
import com.qian.apiserver.model.Withdrawal;

public abstract class WithdrawalServiceBase extends BaseServiceImpl<Withdrawal, GmWithdrawal, Integer> implements IWithdrawalService {

	@Autowired
	private WithdrawalDao dao;

	@Override protected WithdrawalDao getDao() {
	return dao;
	}

	@Override
	protected Withdrawal entity2model(GmWithdrawal entity) {
		Withdrawal model = null;
		if(isNotEmpty(entity)){
			model = new Withdrawal();
			model.setId(entity.getId());
			model.setMoney(entity.getMoney());
			model.setTime(entity.getTime());
			model.setWay(entity.getWay());
			model.setPhone(entity.getPhone());
			model.setCardholder(entity.getCardholder());
			model.setWithdrawalNumber(entity.getWithdrawalNumber());
			model.setStatus(entity.getStatus());
			model.setUserId(entity.getUserId());
		}
		return model;
	}

	@Override
	protected GmWithdrawal model2Entity(Withdrawal model) {
		GmWithdrawal entity = null;
		if(isNotEmpty(model)){
			entity = new GmWithdrawal();
			entity.setId(model.getId());
			entity.setMoney(model.getMoney());
			entity.setTime(model.getTime());
			entity.setWay(model.getWay());
			entity.setPhone(model.getPhone());
			entity.setCardholder(model.getCardholder());
			entity.setWithdrawalNumber(model.getWithdrawalNumber());
			entity.setStatus(model.getStatus());
			entity.setUserId(model.getUserId());
		}
		return entity;
	}

	@Override
	protected GmWithdrawal updateParams(Withdrawal model) {
		GmWithdrawal entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getMoney()))
			entity.setMoney(model.getMoney());
		if(isNotEmpty(model.getTime()))
			entity.setTime(model.getTime());
		if(isNotEmpty(model.getWay()))
			entity.setWay(model.getWay());
		if(isNotEmpty(model.getPhone()))
			entity.setPhone(model.getPhone());
		if(isNotEmpty(model.getCardholder()))
			entity.setCardholder(model.getCardholder());
		if(isNotEmpty(model.getWithdrawalNumber()))
			entity.setWithdrawalNumber(model.getWithdrawalNumber());
		if(isNotEmpty(model.getStatus()))
			entity.setStatus(model.getStatus());
		if(isNotEmpty(model.getUserId()))
			entity.setUserId(model.getUserId());
		return entity;
	}


}